<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <span>{{counter}}</span>
      <input type="button" value="事件-直接写表达式" v-on:click="counter++" />
      <input type="button" value="事件关联方法" v-on:click="handle" />
      <input type="button" value="事件-关联方法(简写形式)" @click="handle" />
    </div>
    <script src="../lib/vue.js"></script>
    <script>
      let vm = new Vue({
        el: '#app',
        data: {
          counter: 0,
        },
        methods: {
          handle: function () {
            alert('单击')
            //this指向的是Vue实例，不是引发事件的元素
            console.log(this)
            console.log(this === vm)
          },
        },
      })
    </script>
  </body>
</html>
